package callgraph.process;

import callgraph.domain.JarConfig;
import callgraph.domain.ProfilingFilter;
import callgraph.util.JavaCGConstants;

import java.io.BufferedWriter;
import java.util.Map;
import java.util.Set;
import java.util.jar.JarFile;

class RecordMethodAnnotationInfo extends CallGraphProcessor {

    public RecordMethodAnnotationInfo(CallGraphProcessStorage storage, ProfilingFilter profilingFilter, JarConfig jarConfig, JarFile jarFile, BufferedWriter resultWriter) {
        super(storage, profilingFilter, jarConfig, jarFile, resultWriter);
    }

    @Override
    public boolean handle() {
        for (Map.Entry<String, Set<String>> entry : storage.getMethodAnnotationMap().entrySet()) {
            String fullMethod = entry.getKey();
            Set<String> annotationSet = entry.getValue();
            for (String annotation : annotationSet) {
                String methodWithAnnotation = fullMethod + " " + annotation + JavaCGConstants.NEW_LINE;
                writeResult("====print annotation information===");
                writeResult(methodWithAnnotation);
            }
        }
        return true;
    }

    @Override
    public CallGraphProcessor next() {
        return null;
    }
}
